<?php
/*
 * This page is called via AJAX to validate the access code submited
 * by a user on enroll.php
 */

include 'common.php';
session_start();

$id = $_REQUEST['imageshield_id'];
$code = $_REQUEST['access_code'];

header('Content-type: application/xml');
if ($code == '') {
    exit('<authentication><result>false</result><type>no_access_code</type></authentication>');
}

if ($id == '') {
    exit("<authentication><result>false</result><type>no_imageshield_id</type></authentication>");
}

$iss = $vs->get_service('imageshield');
if ($iss->verify_code($id, $code)) {
    unset($_SESSION['imageShield']);
    $_SESSION['imageshield_validation'] = true;
    exit("<authentication><result>true</result><type/></authentication>");
}
else {
    exit("<authentication><result>false</result><type/></authentication>");
}
